package com.helen.adapter;

import android.graphics.Color;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.helen.entity.LingQianEntity;
import com.helen.entity.RecoveryCarDetailEntity;
import com.helen.shopping.R;
import com.helen.utils.MyLog;

import java.util.List;


/**
 * Created by yang on 2018/5/2.
 */

public class RecoveryCarDetailListAdapter extends BaseQuickAdapter<RecoveryCarDetailEntity, BaseViewHolder> {
    private int blueColor = Color.parseColor("#66B437");
    private int yellowColor = Color.parseColor("#FF7A00");

    public RecoveryCarDetailListAdapter(List<RecoveryCarDetailEntity> data) {
        super(R.layout.item_lingqian_list, data);

    }


    @Override
    protected void convert(final BaseViewHolder helper, final RecoveryCarDetailEntity item) {
        try {
            TextView tvTitle = (TextView) helper.getView(R.id.tv_title);
            TextView tvTime = (TextView) helper.getView(R.id.tv_time);
            TextView tvJiaJian = (TextView) helper.getView(R.id.tv_jia_jian);
            TextView tvAmount = (TextView) helper.getView(R.id.tv_amount);
            LinearLayout llBg = (LinearLayout) helper.getView(R.id.ll_bg);
            tvTitle.setText(item.getTitle());
            tvTime.setText(item.getCreateTime());
            String amount = item.getMoney();
            if (amount.contains("-")) {
                tvJiaJian.setBackgroundResource(R.drawable.wallet_yellow_left_bg);
                llBg.setBackgroundResource(R.drawable.wallet_yellow_right_bg);
                tvJiaJian.setText("-");
                tvJiaJian.setTextColor(yellowColor);
            } else {
                tvJiaJian.setBackgroundResource(R.drawable.wallet_left_bg);
                llBg.setBackgroundResource(R.drawable.wallet_right_bg);
                tvJiaJian.setText("+");
                tvJiaJian.setTextColor(blueColor);
            }
            tvAmount.setText(amount);
        } catch (Exception e) {
            MyLog.e("yang", "零钱列表异常" + e.toString());
        }


    }


}
